home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* liblog.c */
- /* */
- /* Citadel log code for the library */
- /************************************************************************/
-
- /************************************************************************/
- /* history */
- /* */
- /* 85Nov15 HAW File created. */
- /************************************************************************/
-
- /************************************************************************/
- /* contents */
- /* */
- /* getLog() loads requested CTDLLOG record */
- /* putLog() stores a logBuffer into citadel.log */
- /************************************************************************/
-
- #include "ctdl.h"
-
- struct logBuffer logBuf; /* Log buffer of a person */
- int thisLog; /* entry currently in logBuf */
- FILE *logfl; /* log file descriptor */
-
- extern struct config cfg; /* Configuration variables */
-
- /************************************************************************/
- /* getLog() loads requested log record into RAM buffer */
- /************************************************************************/
- getLog(lBuf, n)
- struct logBuffer *lBuf;
- int n;
- {
- long int s, r;
-
- if (lBuf == &logBuf) thisLog = n;
-
- r = sizeof logBuf; /* To get away from overflows */
- s = n * r; /* This should be offset */
- n *= 3;
-
- if (cfg.weAre != CONFIGUR)
- fseek(logfl, s, 0);
- if (fread(lBuf, sizeof logBuf, 1, logfl) != 1) {
- crashout("?getLog-read fail//EOF detected!");
- }
-
- crypte(lBuf, sizeof logBuf, n); /* decode buffer */
- }
-
- /************************************************************************/
- /* putLog() stores given log record into ctdllog.sys */
- /************************************************************************/
- putLog(lBuf, n)
- struct logBuffer *lBuf;
- int n;
- {
- long int s, r;
-
- r = sizeof logBuf;
- s = n * r;
- n *= 3;
- crypte(lBuf, sizeof logBuf, n); /* encode buffer */
-
- if (cfg.weAre != CONFIGUR) /* No need if configuring */
- fseek(logfl, s, 0);
- if (fwrite(lBuf, sizeof logBuf, 1, logfl) != 1) {
- crashout("?putLog-write fail");
- }
-
- crypte(lBuf, sizeof logBuf, n); /* decode buffer */
- }
-